/*
 * @Author: caisue
 * @version: V1.0.0
 * @Date: 2025-04-29 09:05:19
 * @LastEditors: caisue
 * @LastEditTime: 2025-06-03 11:03:45
 * @Descripttion: 
 */
// 列模型
export function columnSchema(id) {
  return {
    prop: `column${id + 1}`,
    label: `列${id + 1}`,
    width: '',
    minWidth: '',
    align: 'center',
    sortable: false,
    resizable: false,
    showOverflowTooltip: false,
    fixed: null,
    _columnDataType: 'text',
    _customerHTML: '',
    _editType: 'text'
  }
}
export function directSchema() {
  return {
    type: 'static', // 字典类型  static 静态  dynamic 动态
    name: '', // 字典名称
    data: '', // 字典数据 [ {label,value},{label,value},{label,value} ] -- 字符串
    arrData: [], // 字典数据 [ {label,value},{label,value},{label,value} ] -- 数组
    method: 'get', // 请求方式
    url: '', // 求请地址
    requestBody: '', // 请求体
    map: '' // 映射函数
  }
}
export const formConf = {
  formRef: 'elForm',
  formModel: 'formData',
  size: 'medium',
  labelPosition: 'right',
  labelWidth: 100,
  formRules: 'rules',
  gutter: 15,
  disabled: false,
  span: 24,
  formBtns: true,
  // padding: [12, 10, 12, 10],
}

export const inputComponents = [{
    label: '单行文本',
    tag: 'el-input',
    tagIcon: 'input',
    placeholder: '请输入',
    defaultValue: undefined,
    span: 24,
    labelWidth: null,
    style: {
      width: '100%'
    },
    clearable: true,
    prepend: '',
    append: '',
    'prefix-icon': '',
    'suffix-icon': '',
    maxlength: null,
    'show-word-limit': false,
    readonly: false,
    disabled: false,
    required: true,
    regList: [],
    changeTag: true,
    document: 'https://element.eleme.cn/#/zh-CN/component/input'
  },
  {
    label: '多行文本',
    tag: 'el-input',
    tagIcon: 'textarea',
    type: 'textarea',
    placeholder: '请输入',
    defaultValue: undefined,
    span: 24,
    labelWidth: null,
    autosize: {
      minRows: 4,
      maxRows: 4
    },
    style: {
      width: '100%'
    },
    maxlength: null,
    'show-word-limit': false,
    readonly: false,
    disabled: false,
    required: true,
    regList: [],
    changeTag: true,
    document: 'https://element.eleme.cn/#/zh-CN/component/input'
  },
  {
    label: '密码',
    tag: 'el-input',
    tagIcon: 'password',
    placeholder: '请输入',
    defaultValue: undefined,
    span: 24,
    'show-password': true,
    labelWidth: null,
    style: {
      width: '100%'
    },
    clearable: true,
    prepend: '',
    append: '',
    'prefix-icon': '',
    'suffix-icon': '',
    maxlength: null,
    'show-word-limit': false,
    readonly: false,
    disabled: false,
    required: true,
    regList: [],
    changeTag: true,
    document: 'https://element.eleme.cn/#/zh-CN/component/input'
  },
  {
    label: '计数器',
    tag: 'el-input-number',
    tagIcon: 'number',
    placeholder: '',
    defaultValue: undefined,
    span: 24,
    labelWidth: null,
    min: undefined,
    max: undefined,
    step: undefined,
    'step-strictly': false,
    precision: undefined,
    'controls-position': '',
    disabled: false,
    required: true,
    regList: [],
    changeTag: true,
    document: 'https://element.eleme.cn/#/zh-CN/component/input-number'
  },
  {
    label: '编辑器',
    showLabel: true,
    changeTag: true,
    labelWidth: null,
    tag: 'tinymce',
    tagIcon: 'rich-text',
    defaultValue: null,
    span: 24,
    layout: 'colFormItem',
    required: true,
    regList: [],
    document: 'http://tinymce.ax-z.cn',
    placeholder: '请输入',
    height: 300, // 编辑器高度
    branding: false // 隐藏右下角品牌烙印
  },
]

export const selectComponents = [{
    label: '下拉选择',
    tag: 'el-select',
    tagIcon: 'select',
    placeholder: '请选择',
    defaultValue: undefined,
    span: 24,
    labelWidth: null,
    style: {
      width: '100%'
    },
    clearable: true,
    disabled: false,
    required: true,
    filterable: false,
    multiple: false,
    options: [{
      label: '选项一',
      value: 1
    }, {
      label: '选项二',
      value: 2
    }],
    regList: [],
    changeTag: true,
    document: 'https://element.eleme.cn/#/zh-CN/component/select'
  },
  {
    label: '级联选择',
    tag: 'el-cascader',
    tagIcon: 'cascader',
    placeholder: '请选择',
    defaultValue: [],
    span: 24,
    labelWidth: null,
    style: {
      width: '100%'
    },
    props: {
      props: {
        multiple: false
      }
    },
    'show-all-levels': true,
    disabled: false,
    clearable: true,
    filterable: false,
    required: true,
    options: [{
      id: 1,
      value: 1,
      label: '选项1',
      children: [{
        id: 2,
        value: 2,
        label: '选项1-1'
      }]
    }],
    dataType: 'dynamic',
    labelKey: 'label',
    valueKey: 'value',
    childrenKey: 'children',
    separator: '/',
    regList: [],
    changeTag: true,
    document: 'https://element.eleme.cn/#/zh-CN/component/cascader'
  },
  {
    label: '单选框组',
    tag: 'el-radio-group',
    tagIcon: 'radio',
    defaultValue: undefined,
    span: 24,
    labelWidth: null,
    style: {},
    optionType: 'default',
    border: false,
    size: 'medium',
    disabled: false,
    required: true,
    options: [{
      label: '选项一',
      value: 1
    }, {
      label: '选项二',
      value: 2
    }],
    regList: [],
    changeTag: true,
    document: 'https://element.eleme.cn/#/zh-CN/component/radio'
  },
  {
    label: '多选框组',
    tag: 'el-checkbox-group',
    tagIcon: 'checkbox',
    defaultValue: [],
    span: 24,
    labelWidth: null,
    style: {},
    optionType: 'default',
    border: false,
    size: 'medium',
    disabled: false,
    required: true,
    options: [{
      label: '选项一',
      value: 1
    }, {
      label: '选项二',
      value: 2
    }],
    regList: [],
    changeTag: true,
    document: 'https://element.eleme.cn/#/zh-CN/component/checkbox'
  },
  {
    label: '开关',
    tag: 'el-switch',
    tagIcon: 'switch',
    defaultValue: false,
    span: 24,
    labelWidth: null,
    style: {},
    disabled: false,
    required: true,
    'active-text': '',
    'inactive-text': '',
    'active-color': null,
    'inactive-color': null,
    'active-value': true,
    'inactive-value': false,
    regList: [],
    changeTag: true,
    document: 'https://element.eleme.cn/#/zh-CN/component/switch'
  },
  {
    label: '滑块',
    tag: 'el-slider',
    tagIcon: 'slider',
    defaultValue: null,
    span: 24,
    labelWidth: null,
    disabled: false,
    required: true,
    min: 0,
    max: 100,
    step: 1,
    'show-stops': false,
    range: false,
    regList: [],
    changeTag: true,
    document: 'https://element.eleme.cn/#/zh-CN/component/slider'
  },
  {
    label: '时间选择',
    tag: 'el-time-picker',
    tagIcon: 'time',
    placeholder: '请选择',
    defaultValue: null,
    span: 24,
    labelWidth: null,
    style: {
      width: '100%'
    },
    disabled: false,
    clearable: true,
    required: true,
    'picker-options': {
      selectableRange: '00:00:00-23:59:59'
    },
    format: 'HH:mm:ss',
    'value-format': 'HH:mm:ss',
    regList: [],
    changeTag: true,
    document: 'https://element.eleme.cn/#/zh-CN/component/time-picker'
  },
  {
    label: '时间范围',
    tag: 'el-time-picker',
    tagIcon: 'time-range',
    defaultValue: null,
    span: 24,
    labelWidth: null,
    style: {
      width: '100%'
    },
    disabled: false,
    clearable: true,
    required: true,
    'is-range': true,
    'range-separator': '至',
    'start-placeholder': '开始时间',
    'end-placeholder': '结束时间',
    format: 'HH:mm:ss',
    'value-format': 'HH:mm:ss',
    regList: [],
    changeTag: true,
    document: 'https://element.eleme.cn/#/zh-CN/component/time-picker'
  },
  {
    label: '日期选择',
    tag: 'el-date-picker',
    tagIcon: 'date',
    placeholder: '请选择',
    defaultValue: null,
    type: 'date',
    span: 24,
    labelWidth: null,
    style: {
      width: '100%'
    },
    disabled: false,
    clearable: true,
    required: true,
    format: 'yyyy-MM-dd',
    'value-format': 'yyyy-MM-dd',
    readonly: false,
    regList: [],
    changeTag: true,
    document: 'https://element.eleme.cn/#/zh-CN/component/date-picker'
  },
  {
    label: '日期范围',
    tag: 'el-date-picker',
    tagIcon: 'date-range',
    defaultValue: null,
    span: 24,
    labelWidth: null,
    style: {
      width: '100%'
    },
    type: 'daterange',
    'range-separator': '至',
    'start-placeholder': '开始日期',
    'end-placeholder': '结束日期',
    disabled: false,
    clearable: true,
    required: true,
    format: 'yyyy-MM-dd',
    'value-format': 'yyyy-MM-dd',
    readonly: false,
    regList: [],
    changeTag: true,
    document: 'https://element.eleme.cn/#/zh-CN/component/date-picker'
  },
  {
    label: '评分',
    tag: 'el-rate',
    tagIcon: 'rate',
    defaultValue: 0,
    span: 24,
    labelWidth: null,
    style: {},
    max: 5,
    'allow-half': false,
    'show-text': false,
    'show-score': false,
    disabled: false,
    required: true,
    regList: [],
    changeTag: true,
    document: 'https://element.eleme.cn/#/zh-CN/component/rate'
  },
  {
    label: '颜色选择',
    tag: 'el-color-picker',
    tagIcon: 'color',
    defaultValue: null,
    labelWidth: null,
    'show-alpha': false,
    'color-format': '',
    disabled: false,
    required: true,
    size: 'medium',
    regList: [],
    changeTag: true,
    document: 'https://element.eleme.cn/#/zh-CN/component/color-picker'
  },
  {
    label: '上传',
    tag: 'el-upload',
    tagIcon: 'upload',
    action: 'https://jsonplaceholder.typicode.com/posts/',
    defaultValue: null,
    labelWidth: null,
    disabled: false,
    required: true,
    accept: '',
    name: 'file',
    'auto-upload': true,
    showTip: false,
    buttonText: '点击上传',
    fileSize: 2,
    sizeUnit: 'MB',
    'list-type': 'text',
    multiple: false,
    regList: [],
    changeTag: true,
    document: 'https://element.eleme.cn/#/zh-CN/component/upload'
  }
]

export const layoutComponents = [{
    layout: 'rowFormItem',
    tagIcon: 'row',
    type: 'default',
    justify: 'start',
    align: 'top',
    label: '行容器',
    layoutTree: true,
    children: [],
    document: 'https://element.eleme.cn/#/zh-CN/component/layout'
  },
  // {
  //   layout: 'colFormItem',
  //   label: '按钮',
  //   changeTag: true,
  //   labelWidth: null,
  //   tag: 'el-button',
  //   tagIcon: 'button',
  //   span: 24,
  //   default: '主要按钮',
  //   type: 'primary',
  //   icon: 'el-icon-search',
  //   size: 'medium',
  //   disabled: false,
  //   document: 'https://element.eleme.cn/#/zh-CN/component/button'
  // },
  {
    layout: 'tableCellItem',
    label: '表格布局',
    tag: 'table-cell',
    tagIcon: 'table-cell',
    type: 'default',
    span: 24,
    children: [],
    boderColor: "#009688",
    CELL_DEFAULT: {
      rowspan: 1,
      colspan: 1,
      merged: false,
      visible: true,
      rowHeight: 80 // 默认行高
    },
    tableData: [],
    activeCell: { row: -1, col: -1 },
    contextMenu: {
      visible: false,
      position: { x: 0, y: 0 },
      row: -1,
      col: -1
    },
    cellActions: [
      { type: "add-left", icon: "el-icon-s-fold" },
      { type: "add-right", icon: "el-icon-s-unfold" },
      { type: "add-top", icon: "el-icon-top" },
      { type: "add-bottom", icon: "el-icon-bottom" },
      { type: "other-actions", icon: "el-icon-menu" },
    ],
    contextMenuItems:[
      { command: 'add-col-left', label: '左侧插入列', icon: 'el-icon-circle-plus-outline' },
      { command: 'add-col-right', label: '右侧插入列', icon: 'el-icon-circle-plus-outline' },
      { command: 'add-row-top', label: '上方插入行', icon: 'el-icon-circle-plus-outline' },
      { command: 'add-row-bottom', label: '下方插入行', icon: 'el-icon-circle-plus-outline' },
      { type: 'separator' },
      { command: 'merge-right', label: '向右合并', icon: 'el-icon-d-arrow-right' },
      { command: 'merge-down', label: '向下合并', icon: 'el-icon-arrow-down' },
      { type: 'separator' },
      { command: 'split-cell', label: '拆分单元格', icon: 'el-icon-rank' },
      { type: 'separator' },
      { command: 'delete-row', label: '删除当前行', icon: 'el-icon-remove' },
      { command: 'delete-col', label: '删除当前列', icon: 'el-icon-remove' }
    ],
    drag: false,
    // 空数组之在的样式，设置了这个样式才能拖入
    emptyStyle:'min-height:120px;display: block;',
    document: ''
  },
]
// 辅助组件
export const assistantComponents = [
  {
    label: '文字组件',
    tag: 'el-text',
    tagIcon: 'text',
    defaultValue: '默认文本',
    span: 24,
    labelWidth: null,
    clearable: true,
    autosize: {
      minRows: 4,
      maxRows: 4
    },
    maxlength: null,
    'show-word-limit': false,
    readonly: false,
    disabled: false,
    required: false,
    // regList: [],
    changeTag: true,
    document: 'https://element.eleme.cn/#/zh-CN/component/typography',
    // 文本特有属性
    content: '默认文本',
    style: { 
      width: '100%',
      fontSize: '14px',
      color: '#606266',
      fontWeight: 'normal',
      fontStyle: 'normal',
      textAlign: 'left',
      fontFamily: '微软雅黑',
    },
  },
  {
    label: '标题组件',
    tag: 'el-title',
    tagIcon: 'el-title',
    tagLevel: 1,
    defaultValue: '默认标题',
    span: 24,
    labelWidth: null,
    clearable: true,
    autosize: {
      minRows: 4,
      maxRows: 4
    },
    maxlength: null,
    'show-word-limit': false,
    readonly: false,
    disabled: false,
    required: false,
    // regList: [],
    changeTag: true,
    document: 'https://element.eleme.cn/#/zh-CN/component/typography',
    // 文本特有属性
    content: '默认标题',
    style: { 
      width: '100%',
      // fontSize: '14px',
      color: '#606266',
      // fontWeight: 'normal',
      fontStyle: 'normal',
      textAlign: 'left',
      fontFamily: '微软雅黑',
    },
  },
// {
//   default: '暂无数据',
//   layout: 'colFormItem',
//   label: '表格数据',
//   tag: "el-table",
//   tagIcon: "table",
//   span: 24,
//   defaultValue: undefined,
//   columns: [{
//     prop: 'date',
//     label: '日期',
//     width: 180,
//     isTooltip: true,
//   }, {
//     prop: 'name',
//     label: '姓名',
//     width: 180,
//     isTooltip: true,
//   }, {
//     prop: 'address',
//     label: '地址',
//     width: 180,
//     isTooltip: true,
//   }, ],
//   data: [{
//     date: '2016-05-02',
//     name: '王小虎',
//     address: '上海市普陀区金沙江路 1518 弄'
//   }, {
//     date: '2016-05-04',
//     name: '王小虎',
//     address: '上海市普陀区金沙江路 1517 弄'
//   }, {
//     date: '2016-05-01',
//     name: '王小虎',
//     address: '上海市普陀区金沙江路 1519 弄'
//   }, ],
//   style: {
//     width: '100%',
//   },
//   minHeight: '250px',
//   dataType: 'dynamic', // 数据类型
//   regList: [],
//   changeTag: true,
//   stripe: true,
//   lazy: true,
//   size: 'mini',
//   highlightCurrentRow: true,
//   document: 'https://element.eleme.io/#/zh-CN/component/table'
// },
{
  // 标签名
  label: '数据表格',
  // 标签
  tag: 'EditTable',
  // icon
  tagIcon: 'table',
  // 默认数据
  defaultValue: [
    {
      column1: '',
      column2: '',
      column3: ''
    },
    {
      column1: '',
      column2: '',
      column3: ''
    },
    {
      column1: '',
      column2: '',
      column3: ''
    }
  ],
  // 布局方式
  layout: 'colFormItem',
  // 布局宽度
  span: 24,
  // 是否显示label
  showLabel: true,
  // label宽度
  labelWidth: null,
  // 列id自动递增
  columnId: 3,
  // 数据类型
  tableDataType: 'static',
  url: '',
  method: '',
  requestBody: '',
  dataPath: '',
  // 默认列信息
  columns: [
    columnSchema(0),
    columnSchema(1),
    columnSchema(2)
  ],
  // 默认字典信息
  directs: [],
  // 表格尺寸
  size: 'medium',
  // 纵边框
  border: true,
  // 是否可新增
  addAble: true,
  // 是否可编辑
  editAble: true,
  // 是否可删除
  delAble: true,
  // 固定序号列
  fixedNumber: false,
  // 固定操作列
  fixedEdit: false,
  // 是否显示序号
  showNumber: true
},
{
  // 标签名
  label: '照片墙',
  // 标签
  tag: 'PhotoWall',
  // icon
  tagIcon: 'photoWall',
  // 默认数据
  defaultValue: [
    'https://cdn.pixabay.com/photo/2018/01/14/23/12/nature-3082832_640.jpg',
    'https://cdn.pixabay.com/photo/2018/08/21/23/29/forest-3622519_640.jpg',
    'https://cdn.pixabay.com/photo/2013/10/02/23/03/mountains-190055_640.jpg',
    'https://cdn.pixabay.com/photo/2017/12/15/13/51/polynesia-3021072_640.jpg'
  ],
  // 布局方式
  layout: 'colFormItem',
  // 布局宽度
  span: 24,
  // 是否显示label
  showLabel: true,
  // label宽度
  labelWidth: null,
  // 图片宽度
  width: 200,
  // 图片高度
  height: 168
}]
// 组件rule的触发方式，无触发方式的组件不生成rule
export const trigger = {
  'el-input': 'blur',
  'el-input-number': 'blur',
  'el-select': 'change',
  'el-radio-group': 'change',
  'el-checkbox-group': 'change',
  'el-cascader': 'change',
  'el-time-picker': 'change',
  'el-date-picker': 'change',
  'el-rate': 'change',
  tinymce: 'blur'
}